<?php
// +----------------------------------------------------------------------
// | Buddy Framework 
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://buddy.woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <xinqiyang@gmail.com>
// +----------------------------------------------------------------------
/**
 * Buddy Loader 
 * Load all scripts of Buddy
 */
if (!defined('APP_NAME') || !defined('BUDDY_PATH') || !defined('PUB_MODE')  || !defined('CONF_PATH')) {
    exit("APP_NAME,BUDDY_PATH,PUB_MODE,APP_PATH,ACTION_PATH,CONF_PATH  MUST DEFINE,PLEASE CHECK Public/index.php \n");
}

//load basic functions
require BUDDY_PATH.DIRECTORY_SEPARATOR.'Functions.php';

//define Service path
define("Service_PATH", dirname(dirname(CONF_PATH)).DIRECTORY_SEPARATOR.'Service');

//load configuration for app
//NEED TO change here.
if (is_file(CONF_PATH.DIRECTORY_SEPARATOR.'load.conf.php')) {
    C(include CONF_PATH.DIRECTORY_SEPARATOR.'load.conf.php');
} else {
	exit("FATAL:Load configuratin file error,please check!");
}

//load core class
$list = include BUDDY_PATH.DIRECTORY_SEPARATOR.'Core.php';
foreach ($list as $key => $file) {
    require_cache($file);
}
//if Pub mode is Web then load Router 
if(defined("PUB_MODE") && PUB_MODE=='WEB' && APP_NAME !== "Api")
{
	require_cache(BUDDY_PATH.DIRECTORY_SEPARATOR.'Router.php');
}

